package cn.wolfcode.wolf2w.service.impl;


import cn.wolfcode.wolf2w.domain.Thee;
import cn.wolfcode.wolf2w.repository.TheeRepository;
import cn.wolfcode.wolf2w.service.ITheeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class TheeServiceImpl implements ITheeService {
    @Autowired
    private TheeRepository theeRepository;


    @Override
    public void insert(Thee thee) {
        theeRepository.save(thee);
    }

    @Override
    public void delete(String id) {
        theeRepository.deleteById(id);
    }

    @Override
    public void update(Thee thee) {
        theeRepository.save(thee);
    }

    @Override
    public Thee findById(String id) {
        Optional<Thee> thee = theeRepository.findById(id);
        return thee.orElse(null);
    }

    @Override
    public List<Thee> findAll() {
        List<Thee> all = theeRepository.findAll();
        return all;
    }


}
